import employees from '@/api/constant/employees'
// 格式化聘用形式
export const formatHireType = (val) => {
  if (!val) return '暂无'
  return employees.hireType.find(item => item.id === (val - 0)).value
}

// 定义入职时间的过滤器
export function formatDate(time, pattern = '') {
  if (!time) return ''
  time = new Date(time)
  const dt = new Date(time)
  const y = dt.getFullYear()
  const m = (dt.getMonth() + 1).toString().padStart(2, '0')
  const d = dt.getDate().toString().padStart(2, '0')
  pattern.toLowerCase() // 传入参数转成小写
  if (pattern.toLowerCase() === 'yyyy-mm-dd') {
    return `${y}-${m}-${d}`
  } else {
    const hh = dt.getHours().toString().padStart(2, '0')
    const mm = dt.getMinutes().toString().padStart(2, '0')
    const ss = dt.getSeconds().toString().padStart(2, '0')
    return `${y}-${m}-${d} ${hh}:${mm}:${ss}`
  }
}

